<?php


namespace UU\Suite\Kernel\Traits;


use GuzzleHttp\Client;
use UU\Suite\Kernel\Contracts\HttpClientInterface;

trait InteractWithClient
{
    /**
     * @var HttpClientInterface|null
     */
    protected $client = null;

    public function getClient(): HttpClientInterface
    {
        if (!$this->client) {
            $this->client = $this->createClient();
        }

        return $this->client;
    }

    public function setClient(HttpClientInterface $client): self
    {
        $this->client = $client;

        return $this;
    }

    abstract public function createClient(): HttpClientInterface;
}